package com.ssr.master.common.interceptor;


import org.apache.log4j.Logger;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @author ZhangPeng
 * @Description //todo 自定义拦截器（实现 HandlerInterceptor ）
 * @date
 * @updateBy
 * @other
 **/

public class PathInterceptor extends  HandlerInterceptorAdapter {


    private static Logger logger = Logger.getLogger(PathInterceptor.class);

    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        String scheme = request.getScheme();
        String serverName = request.getServerName();
        int port = request.getServerPort();
        String path = request.getContextPath();
        String basePath = scheme + "://" + serverName + ":" + port + path;
//        logger.info(basePath);
        request.setAttribute("basePath", basePath);
        return true;
    }
}
